import type { DirectiveBinding } from 'vue'

export default {
  mounted(el: HTMLInputElement, binding: DirectiveBinding) {
    el.addEventListener(
      'keyup',
      (e: KeyboardEvent) => {
        if (e.key.toLocaleLowerCase() !== 'enter') return
        // console.log('enter-e::', e, binding.value)
        const { value } = binding
        console.log('binding:', binding)
        typeof value === 'function' && value()
      },
      { passive: false }
    )
  }
}
